package com.example.mapstruct_demo.dao;

import com.alibaba.fastjson.JSON;
import com.example.mapstruct_demo.pojo.entity.User;
import com.example.mapstruct_demo.pojo.enums.ProfessionEnum;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 77229
 */
@Component
public class TestDao {
    public Object save(User user) {
        String jsonString = JSON.toJSONString(user);
        System.out.println("保存成功:" + jsonString);
        return "success";
    }

    public User getById(Long userId) {
        User user = new User();
        user.setName("1");
        user.setUserId(userId);
        user.setSex(1);
        List<String> tagList = new ArrayList<>();
        tagList.add("a");
        tagList.add("b");
        tagList.add("c");
        user.setTagList(tagList);
        user.setSalary(100.0);
        user.setProfession(ProfessionEnum.PROGRAMMER);
        return user;
    }
}
